// Copyright (c) 2002 HTHK
//******************************************************************/
//Modification History
//******************************************************************/
//CR log no 1364: By Beyes Xia  Date:2004/10/22
//   get system parameter to control the minimum length of password.
//******************************************************************/

// Begin of CRLog 1364 

package admin;

import admin.system.sysparam.*;

import com.ffpc.sql.*;

import java.sql.*;

public class PasswordLength
{
	public int getPasswordLength()
	{
		int pwLength = 5;
		ConnectionFactory connectionFactory = null;
		try
		{   
			connectionFactory = new ConnectionFactory(); 		
    		Connection con = connectionFactory.getConnection();
    	
			SysParamBean sysParam = SysParamProcess.createBean();
			sysParam.setSys_Param_name("password_length");
			SysParamBean[] sysParams = SysParamProcess.find(con,sysParam);
			
			if (sysParams==null || sysParams.length==0)
				return pwLength;
        	else
        	{
           		pwLength = Integer.parseInt(((SysParam)sysParams[0]).getSys_Param_value());
           		return pwLength;
        	}
        }
        catch(Exception e)
        {
        	System.out.println("Exception : "+e.toString());
        	return pwLength;
        }
        finally
        {
            try
            {
            	connectionFactory.finalize();
                return pwLength;
            }
            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }
	}
	
/*	
	public static void main(String[] args)
	{
		PasswordLength pl = new PasswordLength();
		int pwLength = pl.getPasswordLength();
		System.out.println("pwLength = "+pwLength);
	}
*/
}

// End of CRLog 1364		
			
		